package com.hee.erp.modules.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hee.erp.common.R;
import com.hee.erp.modules.entity.AuditLeave;
import com.hee.erp.modules.entity.WfMain;
import com.hee.erp.modules.service.IAuditLeaveService;
import com.hee.erp.modules.service.IAuditLeaveTypeService;
import com.hee.erp.modules.service.IWfMainService;
import com.hee.erp.vo.page.AuditLeavePageParams;
import com.hee.erp.vo.page.WorkflowPageParams;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/modules/auditLeave")
@Api(tags = "请假管理")
public class AuditLeaveController {

    @Autowired
    IAuditLeaveService mainService;

    @Autowired
    IAuditLeaveTypeService auditLeaveTypeService;

    @PostMapping("/save")
    @ApiOperation(value = "保存")
    public R save(@RequestBody @Valid AuditLeave entity){
        mainService.saveDetail(entity);
        return R.success(entity);
    }

    @ApiOperation("delById")
    @GetMapping("/delById")
    public R<Boolean> delById(String id){
        mainService.removeById(id);
        return R.success(true);
    }

    @ApiOperation(value = "getById")
    @GetMapping("/getById")
    public R getById(String id){
        AuditLeave entity = mainService.getDetailById(id);
        return R.success(entity);
    }

    @PostMapping("/listByPage")
    @ApiOperation(value = "listByPage")
    public R<IPage> listByPage(@RequestBody AuditLeavePageParams pageParams){
        IPage page = mainService.listByPage(pageParams);
        return R.success(page);
    }

    @GetMapping("/getAllLeaveTypeList")
    @ApiOperation(value = "getAllLeaveTypeList")
    public R getAllLeaveTypeList(){
        return R.success(auditLeaveTypeService.list());
    }

}
